#ifndef __CLIENTPROTOCOL_H__
#define __CLIENTPROTOCOL_H__

#include <QObject>
#include <QList>
#include <QString>

#include "faketcp.h"
#include "clientprotocolaction.h"
#include "common/status.h"
#include "common/chat.h"

class ClientProtocol: public QObject {

Q_OBJECT

public:
	ClientProtocol(FakeTcp* socket);
	~ClientProtocol();
	
	bool hasReadyActions();
	ClientProtocolAction* getAction();
signals:
	void readyAction();
private slots:
	void readMessage();
private:
	void parseConnection(QString message);
	void parseChat(QString message);
	void parseUser(QString message);
	void parseFriend(QString message);

	FakeTcp* socket;
	QList<ClientProtocolAction*> actions;
};

class ClientConnectionProtocol {
public:
	static void connect(FakeTcp* socket, const QString& login, const QString& password);
	static void disconnect(FakeTcp* socket);
	static void answerKeepAlive(FakeTcp* socket);
};

class ClientChatProtocol {
public:
	static void start(FakeTcp* socket, int id);
	static void invite(FakeTcp* socket, Chat* chat, int id);
	static void send(FakeTcp* socket, Chat* chat, QString message);
	static void exit(FakeTcp* socket, Chat* chat);
};

class ClientUserProtocol {
public:
	static void changePassword(FakeTcp* socket, const QString& oldPassword, const QString& newPassword);
	static void changeStatus(FakeTcp* socket, Status newStatus);
	static void signup(FakeTcp* socket, const QString& login, const QString& password);
};

class ClientFriendProtocol {
public:
	static void invite(FakeTcp* socket, QString friendLogin);
	static void accept(FakeTcp* socket, QString friendLogin);
	static void deny(FakeTcp* socket, QString friendLogin);
	static void remove(FakeTcp* socket, Friend* f);
};

#endif
